<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the MantisCustomFieldProjectTable class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single MantisCustomFieldProjectTable object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a MantisCustomFieldProjectTableMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 *
	 * @package My QCubed Application
	 * @subpackage MetaControls
	 * @property-read MantisCustomFieldProjectTable $MantisCustomFieldProjectTable the actual MantisCustomFieldProjectTable data class being edited
	 * @property QIntegerTextBox $FieldIdControl
	 * @property-read QLabel $FieldIdLabel
	 * @property QIntegerTextBox $ProjectIdControl
	 * @property-read QLabel $ProjectIdLabel
	 * @property QIntegerTextBox $SequenceControl
	 * @property-read QLabel $SequenceLabel
	 * @property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * @property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class MantisCustomFieldProjectTableMetaControlGen extends QBaseClass {
		// General Variables
		/**
		 * @var MantisCustomFieldProjectTable objMantisCustomFieldProjectTable
		 * @access protected
		 */
		protected $objMantisCustomFieldProjectTable;
		/**
		 * @var QForm|QControl objParentObject
		 * @access protected
		 */
		protected $objParentObject;
		/**
		 * @var string strTitleVerb
		 * @access protected
		 */
		protected $strTitleVerb;
		/**
		 * @var boolean blnEditMode
		 * @access protected
		 */
		protected $blnEditMode;

		// Controls that allow the editing of MantisCustomFieldProjectTable's individual data fields
		/**
		 * @var QIntegerTextBox txtFieldId
		 * @access protected
		 */
		protected $txtFieldId;
		/**
		 * @var QIntegerTextBox txtProjectId
		 * @access protected
		 */
		protected $txtProjectId;
		/**
		 * @var QIntegerTextBox txtSequence
		 * @access protected
		 */
		protected $txtSequence;

		// Controls that allow the viewing of MantisCustomFieldProjectTable's individual data fields
		/**
		 * @var QLabel lblFieldId
		 * @access protected
		 */
		protected $lblFieldId;
		/**
		 * @var QLabel lblProjectId
		 * @access protected
		 */
		protected $lblProjectId;
		/**
		 * @var QLabel lblSequence
		 * @access protected
		 */
		protected $lblSequence;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * MantisCustomFieldProjectTableMetaControl to edit a single MantisCustomFieldProjectTable object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single MantisCustomFieldProjectTable object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisCustomFieldProjectTableMetaControl
		 * @param MantisCustomFieldProjectTable $objMantisCustomFieldProjectTable new or existing MantisCustomFieldProjectTable object
		 */
		 public function __construct($objParentObject, MantisCustomFieldProjectTable $objMantisCustomFieldProjectTable) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this MantisCustomFieldProjectTableMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked MantisCustomFieldProjectTable object
			$this->objMantisCustomFieldProjectTable = $objMantisCustomFieldProjectTable;

			// Figure out if we're Editing or Creating New
			if ($this->objMantisCustomFieldProjectTable->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to
		 * edit, or if we are also allowed to create a new one, etc.
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisCustomFieldProjectTableMetaControl
		 * @param integer $intFieldId primary key value
		 * @param integer $intProjectId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing MantisCustomFieldProjectTable object creation - defaults to CreateOrEdit
 		 * @return MantisCustomFieldProjectTableMetaControl
		 */
		public static function Create($objParentObject, $intFieldId = null, $intProjectId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($intFieldId) && strlen($intProjectId)) {
				$objMantisCustomFieldProjectTable = MantisCustomFieldProjectTable::Load($intFieldId, $intProjectId);

				// MantisCustomFieldProjectTable was found -- return it!
				if ($objMantisCustomFieldProjectTable)
					return new MantisCustomFieldProjectTableMetaControl($objParentObject, $objMantisCustomFieldProjectTable);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a MantisCustomFieldProjectTable object with PK arguments: ' . $intFieldId . ', ' . $intProjectId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new MantisCustomFieldProjectTableMetaControl($objParentObject, new MantisCustomFieldProjectTable());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisCustomFieldProjectTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisCustomFieldProjectTable object creation - defaults to CreateOrEdit
		 * @return MantisCustomFieldProjectTableMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intFieldId = QApplication::PathInfo(0);
			$intProjectId = QApplication::PathInfo(1);
			return MantisCustomFieldProjectTableMetaControl::Create($objParentObject, $intFieldId, $intProjectId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisCustomFieldProjectTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisCustomFieldProjectTable object creation - defaults to CreateOrEdit
		 * @return MantisCustomFieldProjectTableMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intFieldId = QApplication::QueryString('intFieldId');
			$intProjectId = QApplication::QueryString('intProjectId');
			return MantisCustomFieldProjectTableMetaControl::Create($objParentObject, $intFieldId, $intProjectId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QIntegerTextBox txtFieldId
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtFieldId_Create($strControlId = null) {
			$this->txtFieldId = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtFieldId->Name = QApplication::Translate('Field Id');
			$this->txtFieldId->Text = $this->objMantisCustomFieldProjectTable->FieldId;
			$this->txtFieldId->Required = true;
			return $this->txtFieldId;
		}

		/**
		 * Create and setup QLabel lblFieldId
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblFieldId_Create($strControlId = null, $strFormat = null) {
			$this->lblFieldId = new QLabel($this->objParentObject, $strControlId);
			$this->lblFieldId->Name = QApplication::Translate('Field Id');
			$this->lblFieldId->Text = $this->objMantisCustomFieldProjectTable->FieldId;
			$this->lblFieldId->Required = true;
			$this->lblFieldId->Format = $strFormat;
			return $this->lblFieldId;
		}

		/**
		 * Create and setup QIntegerTextBox txtProjectId
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtProjectId_Create($strControlId = null) {
			$this->txtProjectId = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtProjectId->Name = QApplication::Translate('Project Id');
			$this->txtProjectId->Text = $this->objMantisCustomFieldProjectTable->ProjectId;
			$this->txtProjectId->Required = true;
			return $this->txtProjectId;
		}

		/**
		 * Create and setup QLabel lblProjectId
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblProjectId_Create($strControlId = null, $strFormat = null) {
			$this->lblProjectId = new QLabel($this->objParentObject, $strControlId);
			$this->lblProjectId->Name = QApplication::Translate('Project Id');
			$this->lblProjectId->Text = $this->objMantisCustomFieldProjectTable->ProjectId;
			$this->lblProjectId->Required = true;
			$this->lblProjectId->Format = $strFormat;
			return $this->lblProjectId;
		}

		/**
		 * Create and setup QIntegerTextBox txtSequence
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtSequence_Create($strControlId = null) {
			$this->txtSequence = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtSequence->Name = QApplication::Translate('Sequence');
			$this->txtSequence->Text = $this->objMantisCustomFieldProjectTable->Sequence;
			$this->txtSequence->Required = true;
			return $this->txtSequence;
		}

		/**
		 * Create and setup QLabel lblSequence
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblSequence_Create($strControlId = null, $strFormat = null) {
			$this->lblSequence = new QLabel($this->objParentObject, $strControlId);
			$this->lblSequence->Name = QApplication::Translate('Sequence');
			$this->lblSequence->Text = $this->objMantisCustomFieldProjectTable->Sequence;
			$this->lblSequence->Required = true;
			$this->lblSequence->Format = $strFormat;
			return $this->lblSequence;
		}



		/**
		 * Refresh this MetaControl with Data from the local MantisCustomFieldProjectTable object.
		 * @param boolean $blnReload reload MantisCustomFieldProjectTable from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objMantisCustomFieldProjectTable->Reload();

			if ($this->txtFieldId) $this->txtFieldId->Text = $this->objMantisCustomFieldProjectTable->FieldId;
			if ($this->lblFieldId) $this->lblFieldId->Text = $this->objMantisCustomFieldProjectTable->FieldId;

			if ($this->txtProjectId) $this->txtProjectId->Text = $this->objMantisCustomFieldProjectTable->ProjectId;
			if ($this->lblProjectId) $this->lblProjectId->Text = $this->objMantisCustomFieldProjectTable->ProjectId;

			if ($this->txtSequence) $this->txtSequence->Text = $this->objMantisCustomFieldProjectTable->Sequence;
			if ($this->lblSequence) $this->lblSequence->Text = $this->objMantisCustomFieldProjectTable->Sequence;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC MANTISCUSTOMFIELDPROJECTTABLE OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's MantisCustomFieldProjectTable instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveMantisCustomFieldProjectTable() {
			try {
				// Update any fields for controls that have been created
				if ($this->txtFieldId) $this->objMantisCustomFieldProjectTable->FieldId = $this->txtFieldId->Text;
				if ($this->txtProjectId) $this->objMantisCustomFieldProjectTable->ProjectId = $this->txtProjectId->Text;
				if ($this->txtSequence) $this->objMantisCustomFieldProjectTable->Sequence = $this->txtSequence->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the MantisCustomFieldProjectTable object
				$this->objMantisCustomFieldProjectTable->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's MantisCustomFieldProjectTable instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteMantisCustomFieldProjectTable() {
			$this->objMantisCustomFieldProjectTable->Delete();
		}



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'MantisCustomFieldProjectTable': return $this->objMantisCustomFieldProjectTable;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to MantisCustomFieldProjectTable fields -- will be created dynamically if not yet created
				case 'FieldIdControl':
					if (!$this->txtFieldId) return $this->txtFieldId_Create();
					return $this->txtFieldId;
				case 'FieldIdLabel':
					if (!$this->lblFieldId) return $this->lblFieldId_Create();
					return $this->lblFieldId;
				case 'ProjectIdControl':
					if (!$this->txtProjectId) return $this->txtProjectId_Create();
					return $this->txtProjectId;
				case 'ProjectIdLabel':
					if (!$this->lblProjectId) return $this->lblProjectId_Create();
					return $this->lblProjectId;
				case 'SequenceControl':
					if (!$this->txtSequence) return $this->txtSequence_Create();
					return $this->txtSequence;
				case 'SequenceLabel':
					if (!$this->lblSequence) return $this->lblSequence_Create();
					return $this->lblSequence;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to MantisCustomFieldProjectTable fields
					case 'FieldIdControl':
						return ($this->txtFieldId = QType::Cast($mixValue, 'QControl'));
					case 'ProjectIdControl':
						return ($this->txtProjectId = QType::Cast($mixValue, 'QControl'));
					case 'SequenceControl':
						return ($this->txtSequence = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>